#include "cpu.h"
#include "rqlist.h"

#define CONTEXT_STACK_SIZE_MIN sizeof(cpu_context_t)

typedef int (* context_entry_t)(void * arg);



typedef enum {
    ready,
    running,
    pending,
    dead
}context_state_t;

typedef struct {
    cpu_context_t *     cpu_ctx;          /* cpu context, always equal with sp */
    unsigned int *      sp;               /* context stack, always equal with cpu_ctx */
    void *              stk_base;         /* stack base */
    unsigned int        stk_size;         /* context stack size */
    unsigned int        prio;             /* priority of this context */
    unsigned int        tickslice;        /* time slice for this context */

    context_entry_t     entry;            /* entry of context */
    void *              arg;              /* argument of entry */

    context_state_t     state;            /* state of context */

    struct rq_list_head node;             /* mount to which list */

    unsigned char       stk_usg;          /* usage of stack */
}context_t;